# -*- coding: utf-8 -*-
from MyApi import *
from mdMyApi import *
import time


def main():
	actionlist = []

	print("create api ins")
	#create trade api
	tradeins = CTradeApi()
	#create md api
	mdins = CMDApi()

	print("start run actionlist")
	#read actionlist
	#local action list check check
	if(os.path.exists("actionlist.local.ini")):
		actionfile = "actionlist.local.ini"
	else:
		actionfile = "actionlist.ini"

	with open(actionfile, 'r') as f:
		for singleaction in f:
			#filter comment line
			if('#' not in singleaction and '//' not in singleaction):
				actionlist.append(singleaction.strip('\n').split('.'))
		f.close()

	#run actionlist
	for [apiins ,singleaction] in actionlist:
		print(apiins, singleaction)
		exec('%s.%s()' % (apiins ,singleaction))
		time.sleep(1)
		input()

if __name__ == '__main__':
	main()